<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Author_accessibility extends CI_Controller {

	function __construct() {
		parent::__construct();
		$this -> form_validation -> set_error_delimiters('<span class="error">', '</span>');
	}

	function index() {
		if ($this -> model_authors -> is_logged_in()) {
			redirect("control-authors");
		} else {
			$this -> form_validation -> set_rules('email', 'Email', 'callback_login_check');
			$this -> form_validation -> set_error_delimiters('<div class="alert alert-danger" style="position:absolute;top:20px;text-align:center; width:92%;">', '</div>');

			if ($this -> form_validation -> run() == FALSE) {
				$this->load->view(AUTHOR."index");
			} else {
				redirect("control-authors");
			}
		}
	}

	function login_check($email) {
		$password = $this -> input -> post("password");

		if (!$this -> model_authors -> login($email, $password)) {
			$this -> form_validation -> set_message('login_check', '<b>Email / Password is not correct !</b>');
			return false;
		}
		return true;
	}

	public function sign_out() {
		$this -> model_authors -> logout();
	}
	public function no_permission_access($module_id=null){
		
		$data['title']="No permission access";
		//load up global data
		$logged_in_author_info = $this -> model_authors -> get_logged_in_author_info();
		//$data['allowed_modules']=$this->Module->get_allowed_modules($logged_in_employee_info->person_id);
		$data['author_info'] = $logged_in_author_info;
		$this -> load -> vars($data);
		$this->load->view(B_MASTER."index",$data);
	}
	
	public function no_permission_modify($module_id=null){
		
		$data['title']="No permission modify";
		//load up global data
		$logged_in_author_info = $this -> model_authors -> get_logged_in_author_info();
		//$data['allowed_modules']=$this->Module->get_allowed_modules($logged_in_employee_info->person_id);
		$data['author_info'] = $logged_in_author_info;
		$this -> load -> vars($data);
		$this->load->view(B_MASTER."index",$data);
	}
}
